home *** CD-ROM | disk | FTP | other *** search
- /*
-
- File: Echo.c
-
- Contains: Sample debugger extension
-
- */
-
-
- #include <Types.h>
- #include <string.h>
- #include "dcmd.h"
-
- /* Prototypes */
- void NumberToHex (long number, unsigned char *hex);
- pascal void CommandEntry (dcmdBlock* paramPtr);
-
- /* The functions */
- void NumberToHex (long number, unsigned char *hex)
- {
- unsigned char digits[17];
- int n;
-
- strcpy ((char *)hex, ".00000000");
- strcpy ((char *)digits, "0123456789ABCDEF");
-
- hex[0] = 8;
- for (n = 8; n >= 1; n--)
- {
- hex[n] = digits[number % 16];
- number = number / 16;
- }
- } // NumberToHex
-
-
- pascal void CommandEntry (dcmdBlock* paramPtr)
- {
- short pos, ch;
- long value;
- Boolean ok;
- unsigned char str[256];
-
- switch (paramPtr->request)
- {
- case dcmdInit:
- break;
-
- case dcmdHelp:
- strcpy((char *)str, (char *)"\p ECHO [params...]");
- dcmdDrawLine (str);
- strcpy((char *)str, (char *)"\p Echo the command line parameters");
- dcmdDrawLine (str);
- break;
-
- case dcmdDoIt:
- do {
- // Save the position so we can rewind if we get an error
- pos = dcmdGetPosition ();
- ch = dcmdGetNextExpression (&value, &ok);
- if (ok)
- { // The expression was parsed correctly
- NumberToHex (value, str);
- dcmdDrawLine (str);
- }
- else
- { // The expression contained an error. Get it as a string
- dcmdSetPosition (pos);
- ch = dcmdGetNextParameter (str);
- dcmdDrawLine (str);
- }
- } while (ch != '\n' && ch != '\r');
- break;
- }
- } // CommandEntry
-
-